<template>
  <div class="swiper-page">
    <div v-swiper:mySwiper="swiperOption" class="swiper-container">
      <div class="swiper-wrapper">
        <div class="swiper-slide" v-for="(item, idx) in swiperData" :key="idx">
          <img :src="item.imgUrl" />
        </div>
      </div>
      <div class="swiper-pagination"></div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      swiperData: [
        { imgUrl: require("../static/images/1.jpg") },
        { imgUrl: require("../static/images/2.jpg") },
        { imgUrl: require("../static/images/3.jpg") },
        { imgUrl: require("../static/images/4.jpg") },
      ],
      swiperOption: {
        pagination: {
          el: ".swiper-pagination",
          bulletClass: "bullet-swiper", // 自定义设置默认类名
          bulletActiveClass: "bullet-active-swiper", // 自定义滑块活跃类名
          clickable: true, // 点击当前滑块切换到对应的轮播图片
        },
        autoplay: {
          delay: 2000,
        },
        paginationClickable: true,
        speed: 800,
        loop: true,
        observer: true,
        observeParents: true,
        autoplayDisableOnInteraction: false,
      },
    };
  },
};
</script>

<style lang="less">
.swiper-page {
  position: relative;
  .swiper-slide {
    width: 100%;
    height: auto;
    // box-shadow: 0 0 30px 3px rgba(77, 97, 140, 0.4);
    img {
      width: 100%;
      max-height: 28rem;
      height: 100%;
      object-fit: cover;
    }
  }
  .swiper-pagination{
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .bullet-swiper {
    display: inline-block;
    width: 12px;
    height: 12px;
    background: #9b9bb6;
    margin-right: 14px;
    border-radius: 50%;
    transition: all .3s;
  }
  .bullet-active-swiper {
    background: @primary-color;
    width: 20px;
    height: 20px;

  }
}
</style>
